package com.cn.wanxi.dao.impl;

import com.cn.wanxi.dao.IProductsDao;
import com.cn.wanxi.model.PageModel;
import com.cn.wanxi.model.ProductModel;
import com.cn.wanxi.util.GetSqlSession;
import com.cn.wanxi.util.JDBC;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class ProductsDaoImpl implements IProductsDao {
    @Override
    public int add(ProductModel productModel) {
        return GetSqlSession.getSqlSession().insert("com.cn.wanxi.dao.IProductsDao.add",productModel);
    }

    @Override
    public List<ProductModel> findAll(PageModel pageModel) {
        return GetSqlSession.getSqlSession().selectList("com.cn.wanxi.dao.IProductsDao.findAll",pageModel);
    }

    @Override
    public List<ProductModel> productsFind() {
        return GetSqlSession.getSqlSession().selectList("com.cn.wanxi.dao.IProductsDao.productsFind");

    }



    @Override
    public List<ProductModel> productsFinds(ProductModel productModel) {
        return GetSqlSession.getSqlSession().selectList("com.cn.wanxi.dao.IProductsDao.productsFinds",productModel);
    }

    @Override
    public List<ProductModel> productsTypeFind() {
        return GetSqlSession.getSqlSession().selectList("com.cn.wanxi.dao.IProductsDao.productsTypeFind");
    }

    @Override
    public List<ProductModel> idFindProduct(ProductModel productModel) {
        return GetSqlSession.getSqlSession().selectList("com.cn.wanxi.dao.IProductsDao.idFindProduct",productModel);
    }

    @Override
    public int getPageCount(ProductModel productModel) {
        return GetSqlSession.getSqlSession().selectOne("com.cn.wanxi.dao.IProductsDao.getPageCount",productModel);
    }

    @Override
    public int deletebyid(int id) {
        return GetSqlSession.getSqlSession().delete("com.cn.wanxi.dao.IProductsDao.deletebyid",id);
    }

    @Override
    public ProductModel findbyId(int productid) {
        return GetSqlSession.getSqlSession().selectOne("com.cn.wanxi.dao.IProductsDao.findbyId",productid);
    }

    @Override
    public int update(ProductModel productModel) {
        return GetSqlSession.getSqlSession().update("com.cn.wanxi.dao.IProductsDao.update",productModel);
    }

    @Override
    public int getCount(ProductModel productModel) {
        return GetSqlSession.getSqlSession().selectOne("com.cn.wanxi.dao.IProductsDao.getCount",productModel);
    }

    @Override
    public List<ProductModel> productTh(ProductModel productModel) {
        return GetSqlSession.getSqlSession().selectList("com.cn.wanxi.dao.IProductsDao.productTh",productModel);
    }
}
